package com.yidao.util;

import java.util.Date;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class DateTimeUtil {
	
	public static String getDateStr(Calendar cal, String pattern){
		SimpleDateFormat df = new SimpleDateFormat(pattern);
		return df.format(cal.getTime());
	}
	
	public static String getDateStr(Date date, String pattern){
		SimpleDateFormat df = new SimpleDateFormat(pattern);
		return df.format(date);
	}
	
	public static String getDateStr(Timestamp timestamp, String pattern){
		SimpleDateFormat df = new SimpleDateFormat(pattern);
		return df.format(new Date(timestamp.getTime()));
	}
}
